package cn.dujinhao.djh.controller;

import com.jfinal.core.Controller;
import com.jfinal.kit.Base64Kit;

import cn.dujinhao.djh.model.User;

public class LoginController extends Controller {
	private User user = new User();

	public void index() {
		this.render("login.html");
	}

	public void login() {

		user=user.findFirst("select * from `user` where ( `user` = '" + this.getPara("useroremail") + "' or `email`='"
				+ this.getPara("useroremail") + "' ) and `password` = '" + Base64Kit.encode(this.getPara("password"))
				+ "'");
		if (user != null) {
			this.setSessionAttr("usersession", user);
			this.redirect("/admin");
		} else {
			this.renderHtml("<script> alert('您输入的用户信息错误，请重新输入');window.history.back(); </script>");
		}
	}

}
